In [1]:
#statewise-duration.csv
#Less than 1 year ->A
#1-4 years->B
#5-9 years->C
#10 Years and Above->D
In [2]:
#Marriage ->A
#Moved After Birth->B
#Moved with Household->C
#Others->D
In [3]:
#Work/Employment -> A
#Bussiness->B
#Education->C
In [4]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
In [5]:
df = pd.read_csv('/home/kakade/Downloads/labour/statewise-duration.csv')
In [6]:
df
Out[6]:
States Persons-Total Male-Total Female-Total Persons-A Male-A Female-A Persons-B Male-B Female-B Persons-C Male-C Female-C Persons-D Male-D Female-D
0 Andaman and Nicobar Islands 79920 42148 37772 6961 3769 3192 19111 9866 9245 12794 6521 6273 41000 21964 19036
1 Andhra Pradesh 13834338 6528589 7305749 643556 309806 333750 2642819 1239024 1403795 2379412 1123482 1255930 8102682 3824031 4278651
2 Arunachal Pradesh 228416 117444 110972 11852 6259 5593 58360 30153 28207 47769 23694 24075 110390 57312 53078
3 Assam 2134837 952731 1182106 81871 38679 43192 333248 139641 193607 323304 137913 185391 1394996 635816 759180
4 Bihar 4423947 1578798 2845149 150538 71906 78632 633339 232672 400667 713864 257807 456057 2914139 1010292 1903847
5 Chandigarh 687851 367570 320281 34481 18917 15564 125496 63944 61552 114815 60014 54801 412816 224558 188258
6 Chhattisgarh 2984364 1292660 1691704 151058 74369 76689 557480 240662 316818 500463 210556 289907 1773611 766197 1007414
7 Dadra and Nagar Haveli 123769 73864 49905 16092 10573 5519 45043 28671 16372 27030 15798 11232 35555 18802 16753
8 Daman and Diu 131638 90346 41292 22087 16467 5620 51007 37117 13890 28250 19542 8708 30230 17178 13052
9 Delhi 7480558 3896329 3584229 321707 168190 153517 1214865 604559 610306 1293486 661133 632353 4645044 2459526 2185518
10 Goa 703246 338573 364673 54989 31178 23811 133610 63557 70053 121045 55648 65397 393073 187905 205168
11 Gujarat 14028712 6967254 7061458 717440 374651 342789 2747324 1392232 1355092 2490553 1248357 1242196 8055936 3943225 4112711
12 Haryana 5321992 2454246 2867746 269245 136098 133147 1011967 461970 549997 974304 446107 528197 3061257 1407159 1654098
13 Himachal Pradesh 469019 231622 237397 33610 18735 14875 111853 58346 53507 83300 41282 42018 239926 113068 126858
14 Jammu and Kashmir 984859 405850 579009 54400 28827 25573 168587 75272 93315 145656 58552 87104 615690 242935 372755
15 Jharkhand 3539308 1509378 2029930 129689 61906 67783 572128 235318 336810 570625 231527 339098 2258954 976639 1282315
16 Karnataka 11473790 5457297 6016493 734942 364858 370084 2544989 1230658 1314331 2134145 1024188 1109957 6048447 2831673 3216774
17 Kerala 7299942 2880703 4419239 449957 206388 243569 1368066 556801 811265 1216002 479949 736053 4261776 1635435 2626341
18 Lakshadweep 15559 9147 6412 4428 3112 1316 5733 3125 2608 2395 1292 1103 3001 1616 1385
19 Madhya Pradesh 8860562 3714729 5145833 425894 204198 221696 1517286 638774 878512 1448368 603348 845020 5459193 2263164 3196029
20 Maharashtra 29379226 14746099 14633127 1699471 894006 805465 5755669 2879582 2876087 5024042 2481908 2542134 16863064 8470899 8392165
21 Manipur 259437 81823 177614 10257 3799 6458 39936 12110 27826 40041 12732 27309 168926 53046 115880
22 Meghalaya 210995 103689 107306 12835 6253 6582 43634 20604 23030 32728 16367 16361 120990 60026 60964
23 Mizoram 249913 123746 126167 11261 5568 5693 48533 23729 24804 41199 20442 20757 148864 73973 74891
24 Nagaland 287045 148108 138937 18883 9812 9071 60547 30494 30053 52840 26893 25947 154607 80826 73781
25 Odisha 3597180 1616436 1980744 189738 97598 92140 700847 321645 379202 594051 260984 333067 2107685 933726 1173959
26 Puducherry 469422 214443 254979 27300 12454 14846 92015 41309 50706 87225 39829 47396 262659 120742 141917
27 Punjab 5979675 2766978 3212697 281369 140044 141325 953647 428956 524691 932262 423583 508679 3807660 1771703 2035957
28 Rajasthan 6392194 2492260 3899934 319205 145896 173309 1108979 442694 666285 1061566 422141 639425 3892952 1476658 2416294
29 Sikkim 94875 48179 46696 6789 3749 3040 22367 11250 11117 16525 7918 8607 49147 25231 23916
30 Tamil Nadu 17680856 8153973 9526883 1017431 480351 537080 3555814 1628340 1927474 2921139 1335385 1585754 10177461 4705395 5472066
31 Tripura 429041 174305 254736 17221 7672 9549 59342 21004 38338 61788 22042 39746 290345 123402 166943
32 Uttar Pradesh 18071595 7417803 10653792 812098 406995 405103 2896262 1240300 1655962 2920297 1231466 1688831 11360980 4498414 6862566
33 Uttarakhand 1710743 810885 899858 107210 58032 49178 358864 172177 186687 301553 139664 161889 940708 439596 501112
34 West Bengal 12947686 5562869 7384817 487700 232212 255488 1757688 696294 1061394 1791989 707346 1084643 8893101 3917394 4975707
35 India 182566510 83370874 99195636 9333565 4653327 4680238 33316455 15312850 18003605 30506825 13855410 16651415 109096865 49389526 59707339
In [7]:
statewise_data = pd.read_csv('/home/kakade/Downloads/labour/statewise-duration.csv')[:-1]
In [8]:
statewise_data.columns
Out[8]:
Index(['States', 'Persons-Total', 'Male-Total', 'Female-Total', 'Persons-A',
       'Male-A', 'Female-A', 'Persons-B', 'Male-B', 'Female-B', 'Persons-C',
       'Male-C', 'Female-C', 'Persons-D', 'Male-D', 'Female-D'],
      dtype='object')
In [9]:
avg_a = np.mean(statewise_data['Persons-A'].values)
avg_d = np.mean(statewise_data['Persons-D'].values)
avg_total = np.mean(statewise_data['Persons-Total'].values)
In [10]:
states_a = statewise_data[statewise_data['Persons-A'] > avg_a]['States'].values
states_d = statewise_data[statewise_data['Persons-D'] > avg_d]['States'].values
states_total = statewise_data[statewise_data['Persons-Total'] > avg_total]['States'].values
In [11]:
min_dur_males = statewise_data[statewise_data['Persons-A'] > avg_a]['Male-A'].values
min_dur_females = statewise_data[statewise_data['Persons-A'] > avg_a]['Female-A'].values
max_dur_males = statewise_data[statewise_data['Persons-D'] > avg_d]['Male-D'].values
max_dur_females = statewise_data[statewise_data['Persons-D'] > avg_d]['Female-D'].values
total_male =statewise_data[statewise_data['Persons-Total'] > avg_total]['Male-Total'].values
total_female = statewise_data[statewise_data['Persons-Total'] > avg_total]['Female-Total'].values
In [12]:
import plotly.graph_objects as px 
import numpy as np
import plotly.graph_objs as go

np.random.seed(42) 

random_x= np.random.randint(1,101,100) 
random_y= np.random.randint(1,101,100) 

x = states_total

plot = px.Figure(data=[go.Bar( name = 'Male', x = x, y = total_male ), 
                       go.Bar( name = 'Female', x = x, y = total_female ) ]) 

plot.update_layout(barmode='stack') 
plot.show()
In [13]:
India = pd.read_csv('/home/kakade/Downloads/labour/statewise-duration.csv').iloc[-1]
In [14]:
India
Out[14]:
States               India
Persons-Total    182566510
Male-Total        83370874
Female-Total      99195636
Persons-A          9333565
Male-A             4653327
Female-A           4680238
Persons-B         33316455
Male-B            15312850
Female-B          18003605
Persons-C         30506825
Male-C            13855410
Female-C          16651415
Persons-D        109096865
Male-D            49389526
Female-D          59707339
Name: 35, dtype: object
In [15]:
# Import libraries 
import numpy as np 
import matplotlib.pyplot as plt 
  
  
# Creating dataset 
cars = ['Less than 1 year' , '1-4 years', '5-9 years', '10 Years and Above']
  
data = [9333565, 33316455, 30506825, 109096865] 
  
  
# Creating explode data 
explode = (0.0, 0.0, 0.0, 0.1) 
  
# Creating color parameters 
colors = ( "orange", "indigo", "brown", "grey") 
  
# Wedge properties 
wp = { 'linewidth' : 1, 'edgecolor' : "black" } 
  
# Creating autocpt arguments 
def func(pct, allvalues): 
    absolute = int(pct / 100.*np.sum(allvalues)) 
    return "{:.1f}%\n({:d})".format(pct, absolute) 
  
# Creating plot 
fig, ax = plt.subplots(figsize =(10, 7)) 
wedges, texts, autotexts = ax.pie(data,  
                                  autopct = lambda pct: func(pct, data), 
                                  explode = explode,  
                                  labels = cars, 
                                  shadow = True, 
                                  colors = colors, 
                                  startangle = 90, 
                                  wedgeprops = wp, 
                                  textprops = dict(color ="white")) 
  
# Adding legend 
ax.legend(wedges, cars, 
          title ="Durations", 
          loc ="center left", 
          bbox_to_anchor =(1, 0, 0.5, 1)) 
  
plt.setp(autotexts, size = 8, weight ="bold") 
ax.set_title("Duration of Migrations in India") 
  
# show plot 
plt.savefig('/home/kakade/Downloads/labour/Duration_migrations_INDIA.png')
In [16]:
informal = pd.read_csv('/home/kakade/Downloads/labour/informal-maha.csv')
formal = pd.read_csv('/home/kakade/Downloads/labour/formal-maha.csv')
In [17]:
# Import libraries 
import numpy as np 
import matplotlib.pyplot as plt 
  
  
# Creating dataset 
cars = ['Marriage', 'Moved After Birth', 'Moved with Household', 'Others','Work/Employment', 'Bussiness', 'Education']

total_rural_migrations = [14979920,6622002,4892833,2076270,5766098,219296,790455]

  
  
# Creating explode data 
explode = (0.0, 0.0, 0.0, 0.2, 0.0, 0.0, 0.0) 
  
# Creating color parameters 
colors = ( "orange", "indigo", "brown", "grey", "yellow", 'violet', 'green') 
  
# Wedge properties 
wp = { 'linewidth' : 1, 'edgecolor' : "black" } 
  
# Creating autocpt arguments 
def func(pct, allvalues): 
    absolute = int(pct / 100.*np.sum(allvalues)) 
    return "{:.1f}%\n".format(pct, absolute) 
  
# Creating plot 
fig, ax = plt.subplots(figsize =(10, 7)) 
wedges, texts, autotexts = ax.pie(total_rural_migrations,  
                                  autopct = lambda pct: func(pct, data), 
                                  explode = explode,  
                                  labels = cars, 
                                  shadow = True, 
                                  colors = colors, 
                                  startangle = 180, 
                                  wedgeprops = wp, 
                                  textprops = dict(color ="black")) 
  
# Adding legend 
ax.legend(wedges, cars, title ="Reasons of Migrations in Maharashtra", loc ="center left", bbox_to_anchor =(1, 0, 0, 1)) 
plt.setp(autotexts, size = 10, weight ="bold") 
plt.savefig('/home/kakade/Downloads/labour/Reasons_for_total_rural_migrations.png')
In [18]:
p = formal[np.logical_and(formal[formal.columns[0]].isin(['Duration-A-Rural']),formal[formal.columns[1]]=='Urban')][['Female-A', 'Female-B', 'Female-C']].values[0]
q = formal[np.logical_and(formal[formal.columns[0]].isin(['Duration-B-Rural']),formal[formal.columns[1]]=='Urban')][['Female-A', 'Female-B', 'Female-C']].values[0]
r = formal[np.logical_and(formal[formal.columns[0]].isin(['Duration-C-Rural']),formal[formal.columns[1]]=='Urban')][['Female-A', 'Female-B', 'Female-C']].values[0]
s = formal[np.logical_and(formal[formal.columns[0]].isin(['Duration-D-Rural']),formal[formal.columns[1]]=='Urban')][['Female-A', 'Female-B', 'Female-C']].values[0]
In [19]:
x = informal[np.logical_and(informal[informal.columns[0]].isin(['Duration-A-Rural']),informal[informal.columns[1]]=='Urban')][['Female-A', 'Female-B', 'Female-C','Female-D']].values[0]
y = informal[np.logical_and(informal[informal.columns[0]].isin(['Duration-B-Rural']),informal[informal.columns[1]]=='Urban')][['Female-A', 'Female-B', 'Female-C', 'Female-D']].values[0]
z = informal[np.logical_and(informal[informal.columns[0]].isin(['Duration-C-Rural']),informal[informal.columns[1]]=='Urban')][['Female-A', 'Female-B', 'Female-C', 'Female-D']].values[0]
w = informal[np.logical_and(informal[informal.columns[0]].isin(['Duration-D-Rural']),informal[informal.columns[1]]=='Urban')][['Female-A', 'Female-B', 'Female-C', 'Female-D']].values[0]
In [20]:
d = pd.DataFrame([x,y,z,w][::-1]).T
In [21]:
j = pd.DataFrame([p,q,r,s][::-1]).T
In [22]:
import plotly.graph_objects as px 
import numpy as np
import plotly.graph_objs as go
np.random.seed(42) 
random_x= np.random.randint(1,101,100) 
random_y= np.random.randint(1,101,100) 

x = ['2010-2011', '2007-2010', '2002-2007', '2001 and before'][::-1]

plot = px.Figure(data=[go.Bar( name = 'Work/Employment', x = x, y = j.iloc[0].values ), 
                        go.Bar( name = 'Business', x = x, y = j.iloc[1].values ),
                      go.Bar( name = 'Education', x = x, y = j.iloc[2].values )
                      ]) 

plot.update_layout(barmode='stack') 
plot.show()
In [23]:
import plotly.graph_objects as px 
import numpy as np
import plotly.graph_objs as go
np.random.seed(42) 
random_x= np.random.randint(1,101,100) 
random_y= np.random.randint(1,101,100) 

x = ['2010-2011', '2007-2010', '2002-2007', '2001 and before'][::-1]

plot = px.Figure(data=[go.Bar( name = 'Marriage', x = x, y = d.iloc[0].values )
                        , 
                        go.Bar( name = 'Moved After Birth', x = x, y = d.iloc[1].values ),
                      go.Bar( name = 'Moved with Household', x = x, y = d.iloc[2].values ),
                       go.Bar( name = 'Others', x = x, y = d.iloc[3].values )
                      ]) 

plot.update_layout(barmode='stack') 
plot.show()
In [ ]: